package thread.base;

/**
 * Created by mHandler on 2018/5/27 0027.
 * Description:睡眠中停止线程
 */
public class Thread_sleep_interrupt extends Thread {


    @Override
    public void run() {
        super.run();
        try {
            for (int i = 0; i<100000; ++i){
                System.out.println("i = "+i);
            }
            System.out.println("run begin");
            Thread.sleep(200000);
            System.out.println("run end");
        } catch (InterruptedException e) {
            System.out.println("先停止，再sleep，进入catch");
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        Thread_sleep_interrupt thr = new Thread_sleep_interrupt();
        thr.start();
        thr.interrupt();
        System.out.println("end");
    }
}
